<?php
namespace App\Http\Controllers\Wxxcx;

use App\Services\Wxxcx\UserService;
use Illuminate\Http\Request;

class UserController extends BaseController
{
    //小程序

    protected $db;

    public function __construct(UserService $service)
    {
        $this->db = $service;
    }

    /**
     * 我的数据
     */
    public function myIndex(Request $request)
    {
        $uid = $request->post('uid', 0);
        $res = $this->db->tongji($uid);
        if ($res['code'] < 0) {
            return $this->toJson(-2, $res['msg']);
        }
        return $this->toJson(0, '', $res['data']);
    }

    /**
     * 我的扫码列表
     */
    public function myScanList(Request $request)
    {
        $uid = $request->post('uid', 0);
        $pages['start'] = $request->post('start', 1);
        $pages['limit'] = $request->post('limit', 10);
        $res = $this->db->getScanList($uid, $pages);
        if ($res['code'] < 0) {
            return $this->toJson(-2, $res['msg']);
        }
        return $this->toJson(0, '', $res['data'], $res['total']);
    }

    /**
     * 我的关注列表
     */
    public function myFollowList(Request $request)
    {
        $uid = $request->post('uid', 0);
        $pages['start'] = $request->post('start', 1);
        $pages['limit'] = $request->post('limit', 10);
        $res = $this->db->getFollowList($uid, $pages);
        if ($res['code'] < -0) {
            return $this->toJson(-2, $res['msg']);
        }
        return $this->toJson(0, '', $res['data'], $res['total']);
    }

    /**
     * 我的评论列表
     */
    public function myReplyList(Request $request)
    {
        $uid = $request->post('uid', 0);
        $pages['start'] = $request->post('start', 1);
        $pages['limit'] = $request->post('limit', 10);
        $res = $this->db->getReplyList($uid, $pages);
        if ($res['code'] < 0) {
            return $this->toJson(-2, $res['msg']);
        }
        return $this->toJson(0, '', $res['data'], $res['total']);
    }

    /**
     * 我的场景列表
     */
    public function mySceneList(Request $request)
    {
        $pages['start'] = $request->post('start', 1);
        $pages['limit'] = $request->post('limit', 10);
        $res = $this->db->getSceneList($pages);
        if ($res['code'] < 0) {
            return $this->toJson(-2, $res['msg']);
        }
        return $this->toJson(0, '', $res['data'], $res['total']);
    }

    /**
     * 我的场景内容列表
     */
    public function mySceneCntList(Request $request)
    {
        $pages['start'] = $request->post('start', 1);
        $pages['limit'] = $request->post('limit', 10);
        $scene_id = $request->post('scene_id', 0);
        $res = $this->db->getSceneCntList($pages, $scene_id);
        if ($res['code'] < 0) {
            return $this->toJson(-2, $res['msg']);
        }
        return $this->toJson(0, '', $res['data']);
    }
}